package top.shen33.yang.model.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.extension.activerecord.Model;

import java.util.ArrayList;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.Version;
import com.baomidou.mybatisplus.annotation.TableId;
import java.io.Serializable;
import java.util.List;
import java.util.stream.Collectors;

import cn.afterturn.easypoi.excel.annotation.Excel;
import com.baomidou.mybatisplus.annotation.TableId;
import top.shen33.yang.base.R;

/**
 * <p>
 * 
 * </p>
 *
 * @author oreilly
 * @since 2018-08-28
 */
public class RbacUser extends Model<RbacUser> {

private static final long serialVersionUID = 1L;


                @TableId(value = "sid", type = IdType.AUTO)
                
    private Integer sid;


    @Excel(name = "用户名",width = 20,orderNum = "0")
    private String username;

        
    private String password;

    @Excel(name = "真实姓名",width = 20,orderNum = "0")
    private String reallyName;

    @Excel(name = "邮箱",width = 20,orderNum = "0")
    private String email;

    @Excel(name = "手机",width = 20,orderNum = "0")
    private String mobile;

    @Excel(name = "状态",width = 20,orderNum = "0")
    private Integer status;

        
    private Date createTime;

        
    private Date updateTime;

        
    private String loginIp;

        
    private Integer loginTimes;

    @TableField(exist = false)
    private List<RbacRole> rbacRoleList ;


    @TableField(exist = false)
    private List<Integer> roleIds = new ArrayList<>();

    public List<Integer> getRoleIds() {
        return roleIds;
    }

    public void setRoleIds(List<Integer> roleIds) {
        this.roleIds = roleIds;
    }

    public List<RbacRole> getRbacRoleList() {
        return rbacRoleList;
    }

    public void setRbacRoleList(List<RbacRole> rbacRoleList) {
        this.rbacRoleList = rbacRoleList;
    }

    public String getRoleNames(){

        if(this.rbacRoleList ==null || this.rbacRoleList.size() ==0){
            return "";
        }

        List<String> roleNameList = this.rbacRoleList.stream().map(role -> role.getName()).collect(Collectors.toList());
        return String.join("**",roleNameList);
    }

    public Integer getSid() {
            return sid;
    }

    public void setSid(Integer sid) {
            this.sid = sid;
    }

    public String getUsername() {
            return username;
    }

    public void setUsername(String username) {
            this.username = username;
    }

    public String getPassword() {
            return password;
    }

    public void setPassword(String password) {
            this.password = password;
    }

    public String getReallyName() {
            return reallyName;
    }

    public void setReallyName(String reallyName) {
            this.reallyName = reallyName;
    }

    public String getEmail() {
            return email;
    }

    public void setEmail(String email) {
            this.email = email;
    }

    public String getMobile() {
            return mobile;
    }

    public void setMobile(String mobile) {
            this.mobile = mobile;
    }

    public Integer getStatus() {
            return status;
    }

    public void setStatus(Integer status) {
            this.status = status;
    }

    public Date getCreateTime() {
            return createTime;
    }

    public void setCreateTime(Date createTime) {
            this.createTime = createTime;
    }

    public Date getUpdateTime() {
            return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
            this.updateTime = updateTime;
    }

    public String getLoginIp() {
            return loginIp;
    }

    public void setLoginIp(String loginIp) {
            this.loginIp = loginIp;
    }

    public Integer getLoginTimes() {
            return loginTimes;
    }

    public void setLoginTimes(Integer loginTimes) {
            this.loginTimes = loginTimes;
    }

    @Override
    protected Serializable pkVal() {
            return this.sid;
    }

    @Override
    public String toString() {
        return "RbacUser{" +
                ", sid=" + sid +
                ", username=" + username +
                ", password=" + password +
                ", reallyName=" + reallyName +
                ", email=" + email +
                ", mobile=" + mobile +
                ", status=" + status +
                ", createTime=" + createTime +
                ", updateTime=" + updateTime +
                ", loginIp=" + loginIp +
                ", loginTimes=" + loginTimes +
        "}";
    }
}
